<div class="row m-n">
    <div class="crumbs-bar">
        <div yb-crumbs></div>
    </div>
    <div tabset type="tab">
        <div tab heading="服务借用单" active="activeFlag[0]" ng-click="changeTab(0)">
            <div class="row wrapper-y-sm">
                <div class="operate-bar col-xs-4 font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="applyOut()"
                        ng-disabled="!btnPermission.serviceBorrowOutAdd"
                        title="{{!btnPermission.serviceBorrowOutAdd?'无权限执行此操作':''}}">新增</button>
                    <button class="btn btn-operate m-r-sm" ng-click="delData('batch')"
                        ng-disabled="!btnPermission.serviceBorrowOutDel"
                        title="{{!btnPermission.serviceBorrowOutDel?'无权限执行此操作':''}}">删除</button>
                </div>
                <div class="search-bar wrapper-none col-xs-8">
                    <div class="btn-group m-l-xs pull-right">
                        <button type="button" class="btn btn-default base-color" ng-click="search()" title="刷新">
                            <i class="yb-icon ico-refresh"></i>
                        </button>
                        <button type="button" class="btn btn-default base-color" title="配置表格列"
                            ng-click="switchToolbar('ColConfig');">
                            <i class="yb-icon ico-set"></i>
                        </button>
                        <div class="btn btn-default base-color" ng-if="!!btnPermission.serviceBorrowOutExport">
                            <div title="导出">
                                <i class="yb-icon ico-export-o"></i>
                            </div>
                            <ul class="more-tool">
                                <li yb-download download-url="exportParam.sectionUrl"
                                    download-param="exportParam.sectionParam" download-key="ids">
                                    <i class="yb-icon ico-export-o"></i> 导出
                                </li>
                                <li yb-download download-url="exportParam.allUrl" download-param="condition" download-duration="3">
                                    <i class="yb-icon ico-export-o"></i> 导出全部
                                </li>
                            </ul>
                        </div>
                    </div>
                    <button class="btn-advance pull-right m-l-xs"
                        ng-click="switchToolbar('AdvanceSearch')">高级搜索</button>
                    <div class="input-group pull-right clearfix">
                        <input type="text" class="form-control txt-search" placeholder="服务借用单号"
                            ng-model="condition.borrowNo">
                        <span class="input-group-addon cursor-pointer" ng-click="search(1)">搜索</span>
                    </div>
                </div>
            </div>
            <div yb-advance-search show-toolbar="toolbarConfig.showAdvanceSearch" search-data="search(1)"
                reset-data="reset()" hide-date="switchDataPicker()">
                <div class="advance-search m-t-sm">
                    <div class="form-group clearfix">
                        <label class="control-label">借用单号：</label>
                        <input type="text" name="borrowNo" ng-model="condition.borrowNo" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">发出仓库：</label>
                        <input type="text" name="warehouseCode" ng-model="condition.warehouseCode" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">出库状态：</label>
                        <select name="status" class="form-control" ng-model="condition.status"
                            ng-options="item.id as item.name for item in outState">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">制单人：</label>
                        <input type="text" name="createName" ng-model="condition.createName" class="form-control">
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">原因：</label>
                        <select name="materialsType" class="form-control" ng-model="condition.reason"
                            ng-options="item.name as item.name for item in reasonList" required yb-focus>
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label">客户：</label>
                        <input type="text" name="customerName" class="form-control" ng-model="condition.customerName">
                    </div>

                    <div class="form-group clearfix">
                        <label class="control-label">服务人员：</label>
                        <input type="text" name="serviceStaffName" class="form-control"
                            ng-model="condition.serviceStaffName">
                    </div>

                    <div class="form-group clearfix m-b-none">
                        <label class="control-label">制单时间：</label>
                        <input type="text" class="form-control date-picker" ng-model="condition.createDateStart"
                            datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="switchDataPicker(0)"
                            is-open="datePickerFlag[0]" close-text="关闭"
                            ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')" modal-size="small"
                            readonly>
                    </div>
                    <div class="form-group clearfix m-b-none">
                        <label class="control-label"></label>
                        <label class="control-label wave-line">~</label>
                    </div>
                    <div class="form-group clearfix">
                        <label class="control-label"></label>
                        <input type="text" class="form-control date-picker" ng-model="condition.createDateEnd"
                            datepicker-popup="{{'yyyy-MM-dd'}}" ng-click="switchDataPicker(1)"
                            is-open="datePickerFlag[1]" close-text="关闭"
                            ng-change="checkDate(condition, 'createDateStart', 'createDateEnd')" modal-size="small"
                            readonly>
                    </div>
                </div>
            </div>
            <div yb-col-config show-toolbar="toolbarConfig.showColConfig" ng-model="tbConf" col-fixed="true"
                has-check-col="true" set-tb-style="setFixedWidth()"></div>
            <div class="main-area">
                <div yb-table-fixed class="table-fixed-wrap fix-left" ele-count="4" scroll-area="right">
                    <div class="th-fixed">
                        <table class="table-fixed border-none" width="{{tbConf.fixedWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="th-check text-center border-l-none">
                                        <div yb-check-box yb-checked="markInfo.allCheckedBill"
                                            yb-click="selectAll(dataList, 'Bill')"></div>
                                    </th>
                                    <th ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                        ng-show="!!itemCol.isShow && !!itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tbConf.fixedWidth"
                                            fixed-width="tbStyle.fixedWidth"></div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="th-scroll-x" ng-style="tbStyle.fixedWidth">
                        <table class="table-fixed border-none" width="{{tbConf.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th ng-repeat="itemCol in tbConf.tableCol track by $index" width="{{itemCol.width}}"
                                        ng-show="!!itemCol.isShow && !itemCol.isFixed">
                                        <div yb-thead-operate ng-model="itemCol" target-width="tbConf.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll-y" ng-show="dataList.length > 0">
                        <table class="table-fixed border-none" width="{{tbConf.fixedWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index" ng-click="selectRow($index)"
                                    ng-class="{'row-selected': $index === markInfo.curRow}">
                                    <td width="40" class="text-center border-l-none">
                                        <div yb-check-box yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, dataList, 'Bill')"></div>
                                    </td>
                                    <td class="spill-dots" ng-repeat="itemCol in tbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !!itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span
                                            ng-if="(!itemCol.clickFn && itemCol.type !== 'operate') || !!itemCol.clickFn">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                            ng-if="(!!itemCol.clickFn ) || !!itemCol.clickFn">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                        <div class="font-0" ng-if="itemCol.type === 'operate'">
                                            <button class="btn btn-operate m-r-xs" ng-click="printBill(item)"
                                                ng-disabled="!btnPermission.serviceBorrowOutPrint"
                                                title="{{!btnPermission.serviceBorrowOutPrint?'无权限执行此操作':''}}">打印</button>
                                            <button class="btn btn-operate m-r-xs" ng-click="outbound(item)"
                                                ng-if="curOrg.isBarcode === 0"
                                                ng-disabled="item.status === 2 || item.status === 3 || !btnPermission.serviceBorrowOutOut"
                                                title="{{!btnPermission.serviceBorrowOutOut?'无权限执行此操作':''}}">出库</button>
                                            <button class="btn btn-operate m-r-xs" ng-click="editData(item)"
                                                ng-disabled="item.status === 2 || item.status === 3 || !btnPermission.serviceBorrowOutEdit"
                                                title="{{!btnPermission.serviceBorrowOutEdit?'无权限执行此操作':''}}">编辑</button>
                                            <button class="btn btn-operate m-r-xs" ng-click="delData('single', item.id)"
                                                ng-disabled="!!item.status || !btnPermission.serviceBorrowOutDel"
                                                title="{{!btnPermission.serviceBorrowOutDel?'无权限执行此操作':''}}">删除</button>
                                            <button class="btn btn-operate m-r-xs" ng-click="obligate(item)"
                                                ng-disabled="item.status===0||item.orderStatus===1||!btnPermission.serviceBorrowOutToSale"
                                                title="{{!btnPermission.serviceBorrowOutToSale?'无权限执行此操作':''}}">转销售</button>
                                            <button class="btn btn-operate m-r-xs" ng-click="goReturn(item)"
                                                ng-disabled="item.status===0||item.orderStatus===1||!btnPermission.serviceBorrowOutToIn"
                                                title="{{!btnPermission.serviceBorrowOutToIn?'无权限执行此操作':''}}">转退回</button>
                                            <button class="btn btn-operate m-r-xs"
                                                ng-click="mandatoryFinish(item.borrowNo)"
                                                ng-disabled="item.status!==1||!btnPermission.mandatoryFinish"
                                                title="{{!btnPermission.mandatoryFinish?'无权限执行此操作':''}}">结单</button>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="dataList.length > 0" ng-style="tbStyle.fixedWidth">
                        <table class="table-fixed border-none" width="{{tbConf.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in dataList track by $index" ng-click="selectRow($index)"
                                    ng-class="{'row-selected': $index === markInfo.curRow}">
                                    <td class="spill-dots" ng-repeat="itemCol in tbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-show="!!itemCol.isShow && !itemCol.isFixed"
                                        title="{{item[itemCol.dataField]}}">
                                        <span
                                            ng-if="!itemCol.clickFn && itemCol.type !== 'operate' ">{{item[itemCol.dataField]}}</span>
                                        <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                            ng-if="!!itemCol.clickFn ">
                                            {{item[itemCol.dataField]}}
                                        </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="dataList.length === 0">暂时没有数据</div>
                </div>
            </div>
            <div class="bottom-area page-bar wrapper-y-sm clearfix">
                <div yb-check-box class="m-t-xs m-r-sm" yb-checked="markInfo.allCheckedBill" yb-check-name="全选"
                    yb-click="selectAll(dataList, 'Bill')"></div>
                <button class="btn btn-operate m-r-sm" ng-click="delData('batch')"
                    ng-disabled="!btnPermission.serviceBorrowOutDel"
                    title="{{!btnPermission.serviceBorrowOutDel?'无权限执行此操作':''}}">删除</button>
                <div yb-page-info ng-model="pageInfo" yb-refresh="search()"></div>
            </div>
        </div>
        <div tab heading="新增" active="activeFlag[1]" ng-if="activeFlag[1]">
            <form name="form" class="m-t-sm form-horizontal form-up-tb border-b clearfix" novalidate>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>服务人员：</label>
                    <div class="col-xs-8 wrapper-none">
                        <input type="text" name="serviceStaffName" class="form-control light-bg"
                            ng-model="orderObj.headerInfo.serviceStaffName" ng-click="searchDispatch()" required
                            yb-focus readonly placeholder="请选择">

                        <div class="msg-block"
                            ng-if="form.serviceStaffName.$dirty || (form.serviceStaffName.$invalid && submitted)">
                            <div class="error-msg"
                                ng-if="form.serviceStaffName.$error.required && !form.serviceStaffName.focused">
                                <div class="msg-triangle"></div>
                                必填项，请填写
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>调出仓库：</label>
                    <div class="col-xs-8 wrapper-none">
                        <div yb-form-clear ng-model="orderObj.headerInfo.warehouseCode" select-obj="selectWarehouse()"
                            clear-form="clearWarehouse()" tips-name="调出仓库" form-require="true"></div>

                        <div class="msg-block" ng-if="!orderObj.headerInfo.warehouseCode && submitted">
                            <div class="error-msg">
                                <div class="msg-triangle"></div>
                                请选择调出仓库
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">客户名称：</label>
                    <div class="col-xs-8 wrapper-none">
                        <div yb-form-clear ng-model="orderObj.headerInfo.customerName" select-obj="selectAgent()"
                            clear-form="clearAgent()" tips-name="客户"></div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>原因：</label>
                    <div class="col-xs-8 wrapper-none">
                        <div dealer-dictionary-selector ng-model="orderObj.headerInfo.reason" sel-key="BORROWREASON">
                            <input type="text" name="reason" class="form-control light-bg"
                                ng-model="orderObj.headerInfo.reason" placeholder="请选择" required readonly yb-focus>
                        </div>

                        <div class="msg-block" ng-if="form.reason.$dirty || (form.reason.$invalid && submitted)">
                            <div class="error-msg" ng-if="form.reason.$error.required && !form.reason.focused">
                                <div class="msg-triangle"></div>
                                必填项，请填写
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">派工单号：</label>
                    <div class="col-xs-8 wrapper-none">
                        <input type="text" name="dispatchNo" class="form-control" maxlength="50"
                            ng-model="orderObj.headerInfo.dispatchNo">
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">备注：</label>
                    <div class="col-xs-8 wrapper-none">
                        <input type="text" name="remark" class="form-control" maxlength="200"
                            ng-model="orderObj.headerInfo.remark">
                    </div>
                </div>
                <div ng-if="serviceStaffQuota && serviceStaffQuota.borrowingQuota" class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">借用额度：</label>
                    <div class="col-xs-8 wrapper-none spill-dots">
                        <input type="text" class="form-control" ng-model="serviceStaffQuota.borrowingQuota" disabled>
                    </div>
                </div>
                <div ng-if="serviceStaffQuota && serviceStaffQuota.borrowingQuota" class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">剩余额度：</label>
                    <div class="col-xs-8 wrapper-none spill-dots">
                        <input type="text" class="form-control" ng-model="serviceStaffQuota.restBorrowAmount" disabled>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">总价：</label>
                    <label class="col-xs-8 control-label p-l-n text-left"
                        title="{{orderObj.headerInfo.totalAmount||'-'}}">
                        {{orderObj.headerInfo.totalAmount || "-"}}
                    </label>
                </div>
                <div class="form-group col-xs-3 m-b-sm" ng-if="!!costPriceShow">
                    <label class="col-xs-4 control-label max-w-100">成本总价：</label>
                    <label class="col-xs-8 control-label p-l-n text-left"
                        title="{{orderObj.headerInfo.costTotal||'-'}}">
                        {{orderObj.headerInfo.costTotal || "-"}}
                    </label>
                </div>
            </form>
            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="selMateriel($event)">选择零件</button>
                    <button class="btn btn-operate m-r-sm" ng-click="importMateriel()">导入零件</button>
                    <button class="btn btn-operate m-r-sm" ng-click="batchDelMateriel()">批量删除</button>
                    <div class="pull-right m-r-xs" title="{{!btnPermission.showCostPrice?'无权限执行此操作':''}}">
                        <label class="font-12 m-r-xs">显示成本价:</label>
                        <toggle ng-model="costPriceShow" yb-disabled="!btnPermission.showCostPrice"></toggle>
                    </div>
                </div>
            </div>
            
            <div materiel-selector show-toolbar="toolbarConfig.showMateriel" selected-list="orderObj.materialList"
                warehouse-code="orderObj.headerInfo.warehouseCode"
                mark-stock-status="true">
            </div>
            <div ng-style="{'top':(serviceStaffQuota&&serviceStaffQuota.borrowingQuota)?'215px':'173px'}"
                class="main-area d-b-60">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{newTbConf.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="th-check text-center">
                                        <div yb-check-box yb-checked="markInfo.allCheckedMaterial"
                                            yb-click="selectAll(orderObj.materialList, 'Material')"></div>
                                    </th>
                                    <th width="80">
                                        操作
                                    </th>
                                    <th ng-repeat="itemCol in newTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-if="itemCol.type!=='cost'||costPriceShow">
                                        <div yb-thead-operate ng-model="itemCol" target-width="newTbConf.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderObj.materialList.length > 0">
                        <table class="table-fixed border-none" width="{{newTbConf.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderObj.materialList track by $index">
                                    <td width="40" class="text-center">
                                        <div yb-check-box yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, orderObj.materialList, 'Material')"></div>
                                    </td>
                                    <td width="80">
                                        <button type="button" class="btn btn-operate"
                                            ng-click="delMateriel(item, $index)">删除</button>
                                    </td>
                                    <td ng-repeat="itemCol in newTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" title="{{item[itemCol.dataField]}}"
                                        ng-if="itemCol.type!=='cost'||costPriceShow">

                                        <div class="spill-dots" ng-if="!itemCol.input">
                                            <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                                ng-if="!!itemCol.clickFn">
                                                {{item[itemCol.dataField]}}
                                            </a>
                                            <span ng-if="!itemCol.clickFn">
                                                {{item[itemCol.dataField]}}
                                            </span>
                                        </div>

                                        <div ng-if="itemCol.input && itemCol.inputType === 'txt'" class="td-edit pos-r">
                                            <input type="text" class="form-control edit"
                                                ng-model="item[itemCol.dataField]" ng-focus="showQtyTip(item)"
                                                ng-blur="hideQtyTip(item)" ng-change="checkStock(item)" yb-number-input
                                                max="99999.999" maxlength="9" disable-decimal="false" decimal-places="3"
                                                ng-class="{'error': !!item.quantityErr, 'high-warning': item.quantityStockErr && (item.quantityStockErrLevel == 3),
                                                    'mid-warning': item.quantityStockErr  && (item.quantityStockErrLevel == 2), 'low-warning': item.quantityStockErr  && (item.quantityStockErrLevel == 1)}">
                                            <div class="pos-a tool-tips"
                                                ng-if="!!item.quantityErr || item.showStockErr">
                                                <i class="triangle"></i>
                                                <div class="msg">{{item.quantityErrMsg}}</div>
                                            </div>
                                        </div>

                                        <div ng-if="itemCol.input && itemCol.inputType === 'price'"
                                            class="td-edit pos-r">
                                            <input type="text" class="form-control edit"
                                                ng-model="item[itemCol.dataField]" ng-change="checkStock(item)"
                                                yb-number-input max="99999.999" maxlength="9" disable-decimal="false"
                                                decimal-places="3" ng-class="{'error': !!item.priceErr}">
                                            <div class="pos-a tool-tips" ng-if="item.priceErr">
                                                <i class="triangle"></i>
                                                <div class="msg">{{item.priceErrMsgTxt}}</div>
                                            </div>
                                        </div>

                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderObj.materialList.length === 0">暂时没有数据
                    </div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData(form.$valid)">提交</button>
                <button type="button" class="btn btn-default m-r-sm" ng-click="cancel()">取消</button>
            </div>
        </div>
        <div tab heading="编辑" active="activeFlag[2]" ng-if="activeFlag[2]">
            <form name="form" class="m-t-sm form-horizontal form-up-tb clearfix" novalidate>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">服务借用单号：</label>
                    <label class="col-xs-8 control-label p-l-n text-left spill-dots"
                        title="{{orderObj.headerInfo.borrowNo  || '-'}}">
                        {{orderObj.headerInfo.borrowNo  || "-"}}
                    </label>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>服务人员：</label>
                    <div class="col-xs-8 wrapper-none">
                        <input type="text" name="serviceStaffName" class="form-control light-bg"
                            ng-model="orderObj.headerInfo.serviceStaffName" ng-click="searchDispatch()" required
                            yb-focus readonly placeholder="请选择">

                        <div class="msg-block"
                            ng-if="form.serviceStaffName.$dirty || (form.serviceStaffName.$invalid && submitted)">
                            <div class="error-msg"
                                ng-if="form.serviceStaffName.$error.required && !form.serviceStaffName.focused">
                                <div class="msg-triangle"></div>
                                必填项，请填写
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">调出仓库：</label>
                    <label class="col-xs-8 control-label p-l-n text-left spill-dots"
                        title="{{orderObj.headerInfo.borrowNo  || '-'}}">
                        {{orderObj.headerInfo.warehouseCode  || "-"}}
                    </label>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">客户名称：</label>
                    <div class="col-xs-8 wrapper-none">
                        <div yb-form-clear ng-model="orderObj.headerInfo.customerName" select-obj="selectAgent()"
                            clear-form="clearAgent()" tips-name="客户"></div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100"><i>*</i>原因：</label>
                    <div class="col-xs-8 wrapper-none">
                        <div dealer-dictionary-selector ng-model="orderObj.headerInfo.reason" sel-key="BORROWREASON">
                            <input type="text" name="reason" class="form-control light-bg"
                                ng-model="orderObj.headerInfo.reason" placeholder="请选择" required readonly yb-focus>
                        </div>

                        <div class="msg-block" ng-if="form.reason.$dirty || (form.reason.$invalid && submitted)">
                            <div class="error-msg" ng-if="form.reason.$error.required && !form.reason.focused">
                                <div class="msg-triangle"></div>
                                必填项，请填写
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">派工单号：</label>
                    <div class="col-xs-8 wrapper-none">
                        <input type="text" name="dispatchNo" class="form-control" maxlength="50"
                            ng-model="orderObj.headerInfo.dispatchNo">
                    </div>
                </div>
                <div ng-if="serviceStaffQuota && serviceStaffQuota.borrowingQuota" class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">借用额度：</label>
                    <div class="col-xs-8 wrapper-none spill-dots">
                        <input type="text" class="form-control" ng-model="serviceStaffQuota.borrowingQuota" disabled>
                    </div>
                </div>
                <div ng-if="serviceStaffQuota && serviceStaffQuota.borrowingQuota" class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">剩余额度：</label>
                    <div class="col-xs-8 wrapper-none spill-dots">
                        <input type="text" class="form-control" ng-model="serviceStaffQuota.restBorrowAmount" disabled>
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">备注：</label>
                    <div class="col-xs-8 wrapper-none">
                        <input type="text" name="remark" class="form-control" maxlength="200"
                            ng-model="orderObj.headerInfo.remark">
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">出库状态：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" style="margin-top: 6px;">
                        {{orderObj.headerInfo.status | ProgressStatus:"outDepot"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 control-label max-w-100">总价：</label>
                    <div class="col-xs-8 wrapper-none" title="{{orderObj.headerInfo.totalAmount||'-'}}"
                        style="margin-top: 6px;">
                        {{orderObj.headerInfo.totalAmount || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm" ng-if="!!costPriceShow">
                    <label class="col-xs-4 control-label max-w-100">成本总价：</label>
                    <div class="col-xs-8 wrapper-none" title="{{orderObj.headerInfo.costTotal||'-'}}"
                        style="margin-top: 6px;">
                        {{orderObj.headerInfo.costTotal || "-"}}
                    </div>
                </div>
            </form>
            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="batchDelMateriel()">批量删除</button>
                    <div class="pull-right m-r-xs" title="{{!btnPermission.showCostPrice?'无权限执行此操作':''}}">
                        <label class="font-12 m-r-xs">显示成本价:</label>
                        <toggle ng-model="costPriceShow" yb-disabled="!btnPermission.showCostPrice"></toggle>
                    </div>
                </div>
            </div>
            <div style="top:218px;" class="main-area d-b-60">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{editTbConf.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="th-check text-center">
                                        <div yb-check-box yb-disabled="item.status===1"
                                            yb-checked="markInfo.allCheckedMaterial"
                                            yb-click="selectAll(orderObj.materialList, 'Material')"></div>
                                    </th>
                                    <th width="80">
                                        操作
                                    </th>
                                    <th ng-repeat="itemCol in editTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-if="itemCol.type!=='cost'||costPriceShow">
                                        <div yb-thead-operate ng-model="itemCol" target-width="editTbConf.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderObj.materialList.length > 0">
                        <table class="table-fixed border-none" width="{{editTbConf.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderObj.materialList track by $index">
                                    <td width="40" class="text-center">
                                        <div yb-check-box yb-disabled="item.status!==0" yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, orderObj.materialList, 'Material')"></div>
                                    </td>
                                    <td width="80">
                                        <button type="button" ng-disabled="item.status!==0" class="btn btn-operate"
                                            ng-click="delMateriel(item, $index)">删除</button>
                                    </td>
                                    <td ng-repeat="itemCol in editTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" title="{{item[itemCol.dataField]}}"
                                        ng-if="itemCol.type!=='cost'||costPriceShow">

                                        <div class="spill-dots"
                                            ng-if="!itemCol.input || item.status == 2 || item.status == 3">
                                            <a class="btn-operate m-r-xs" ng-click="tdClick(item, itemCol.clickFn)"
                                                ng-if="!!itemCol.clickFn">
                                                {{item[itemCol.dataField]}}
                                            </a>
                                            <span ng-if="!itemCol.clickFn">
                                                {{item[itemCol.dataField]}}
                                            </span>
                                        </div>

                                        <div ng-if="itemCol.input && itemCol.inputType === 'txt' && (item.status == 0 || item.status == 1)"
                                            class="td-edit pos-r">
                                            <input type="text" class="form-control edit"
                                                ng-model="item[itemCol.dataField]" ng-focus="showQtyTip(item)"
                                                ng-blur="hideQtyTip(item)" ng-change="checkStock(item)" yb-number-input
                                                max="99999.999" maxlength="9" disable-decimal="false" decimal-places="3"
                                                ng-class="{'error': !!item.quantityErr, 'high-warning': item.quantityStockErr && (item.quantityStockErrLevel == 3),
                                                    'mid-warning': item.quantityStockErr  && (item.quantityStockErrLevel == 2), 'low-warning': item.quantityStockErr  && (item.quantityStockErrLevel == 1)}">
                                            <div class="pos-a tool-tips"
                                                ng-if="!!item.quantityErr || item.showStockErr">
                                                <i class="triangle"></i>
                                                <div class="msg">{{item.quantityErrMsg}}</div>
                                            </div>
                                        </div>
                                        <div ng-if="itemCol.input && itemCol.inputType === 'price' && item.status < 2"
                                            class="td-edit pos-r">
                                            <input type="text" class="form-control edit"
                                                ng-model="item[itemCol.dataField]" ng-change="checkStock(item)"
                                                yb-number-input max="99999.999" maxlength="9" disable-decimal="false"
                                                decimal-places="3" ng-class="{'error': !!item.priceErr}">
                                            <div class="pos-a tool-tips" ng-if="item.priceErr">
                                                <i class="triangle"></i>
                                                <div class="msg">{{item.priceErrMsgTxt}}</div>
                                            </div>
                                        </div>

                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderObj.materialList.length === 0">暂时没有数据
                    </div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm" ng-click="saveData(form.$valid)">提交</button>
                <button type="button" class="btn btn-default m-r-sm" ng-click="cancel()">取消</button>
            </div>
        </div>
        <div tab heading="查看" active="activeFlag[3]" ng-if="activeFlag[3]">
            <div class="m-t-sm form-up-tb clearfix">
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">服务借用单号：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.borrowNo || '-'}}">
                        {{orderObj.headerInfo.borrowNo || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">服务人员：</label>
                    <div class="col-xs-8 wrapper-none spill-dots"
                        title="{{orderObj.headerInfo.serviceStaffName || '-'}}">
                        {{orderObj.headerInfo.serviceStaffName || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">发出仓库：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.warehouseCode || '-'}}">
                        {{orderObj.headerInfo.warehouseCode || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">客户名称：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.customerName  || '-'}}">
                        {{orderObj.headerInfo.customerName  || '-'}}
                    </div>
                </div>

                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">原因：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.reason || '-'}}">
                        {{orderObj.headerInfo.reason || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">派工单号：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.dispatchNo || '-'}}">
                        {{orderObj.headerInfo.dispatchNo || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">备注：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.remark || '-'}}">
                        {{orderObj.headerInfo.remark  || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">出库状态：</label>
                    <div class="col-xs-8 wrapper-none spill-dots">
                        {{orderObj.headerInfo.status | ProgressStatus:"outDepot"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">总价：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.totalAmount || '-'}}">
                        {{orderObj.headerInfo.totalAmount  || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm" ng-if="!!costPriceShow">
                    <label class="col-xs-4 m-b-n text-right max-w-100">成本总价：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.costTotal || '-'}}">
                        {{orderObj.headerInfo.costTotal  || "-"}}
                    </div>
                </div>
            </div>
            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <div class="pull-right m-r-xs" title="{{!btnPermission.showCostPrice?'无权限执行此操作':''}}">
                        <label class="font-12 m-r-xs">显示成本价:</label>
                        <toggle ng-model="costPriceShow" yb-disabled="!btnPermission.showCostPrice"></toggle>
                    </div>
                </div>
            </div>
            <div class="main-area d-b-60" style="top:170px;">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{viewTbConf.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th width="60" class="border-l-none">
                                        操作
                                    </th>
                                    <th ng-repeat="itemCol in viewTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" ng-if="itemCol.type!=='cost'||costPriceShow">
                                        <div yb-thead-operate ng-model="itemCol" target-width="viewTbConf.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderObj.materialList.length > 0">
                        <table class="table-fixed border-none" width="{{viewTbConf.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderObj.materialList track by $index">
                                    <td width="60" class="font-0">
                                        <button class="btn btn-operate"
                                            ng-click="mandatoryFinish(orderObj.headerInfo.borrowNo, orderObj.headerInfo.id, item.materialsNo)"
                                            ng-disabled="orderObj.headerInfo.status!==1||item.status===2||item.status===3||!btnPermission.mandatoryFinish"
                                            title="{{!btnPermission.mandatoryFinish?'无权限执行此操作':''}}">结单</button>
                                    </td>
                                    <td ng-repeat="itemCol in viewTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}" class="spill-dots"
                                        ng-if="itemCol.type!=='cost'||costPriceShow"
                                        title="{{item[itemCol.dataField]}}">
                                        {{item[itemCol.dataField]}}
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderObj.materialList.length === 0">暂时没有数据
                    </div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm"
                    ng-click="mandatoryFinish(orderObj.headerInfo.borrowNo, orderObj.headerInfo.id)"
                    ng-disabled="orderObj.headerInfo.status !== 1 || !btnPermission.mandatoryFinish"
                    title="{{!btnPermission.mandatoryFinish?'无权限执行此操作':''}}">结单</button>
                <button type="button" class="btn btn-default m-r-sm" ng-click="cancel()">返回</button>
            </div>
        </div>
        <div tab heading="出库" active="activeFlag[4]" ng-if="activeFlag[4]">
            <div class="m-t-sm form-up-tb clearfix">
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">服务借用单号：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.borrowNo || '-'}}">
                        {{orderObj.headerInfo.borrowNo || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">服务人员：</label>
                    <div class="col-xs-8 wrapper-none spill-dots"
                        title="{{orderObj.headerInfo.serviceStaffName || '-'}}">
                        {{orderObj.headerInfo.serviceStaffName || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">发出仓库：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.warehouseCode || '-'}}">
                        {{orderObj.headerInfo.warehouseCode || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">客户名称：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.customerName  || '-'}}">
                        {{orderObj.headerInfo.customerName  || '-'}}
                    </div>
                </div>

                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">原因：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.reason || '-'}}">
                        {{orderObj.headerInfo.reason || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">派工单号：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.dispatchNo || '-'}}">
                        {{orderObj.headerInfo.dispatchNo || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">备注：</label>
                    <div class="col-xs-8 wrapper-none spill-dots" title="{{orderObj.headerInfo.remark || '-'}}">
                        {{orderObj.headerInfo.remark  || "-"}}
                    </div>
                </div>
                <div class="form-group col-xs-3 m-b-sm">
                    <label class="col-xs-4 m-b-n text-right max-w-100">出库状态：</label>
                    <div class="col-xs-8 wrapper-none spill-dots">
                        {{orderObj.headerInfo.status | ProgressStatus:"outDepot"}}
                    </div>
                </div>

            </div>
            <div class="panel-bar clearfix">
                <div class="pull-left">
                    <i></i>零件信息
                </div>
            </div>
            <div class="row wrapper-y-xs">
                <div class="col-xs-12 operate-bar font-0">
                    <button class="btn btn-operate m-r-sm" ng-click="multiSelDepot()">批量选择储位</button>
                </div>
            </div>
            <div class="main-area d-b-60" style="top:175px;">
                <div yb-table-fixed class="table-fixed-wrap">
                    <div class="th-scroll-x">
                        <table class="table-fixed border-none" width="{{outTbConf.scrollWidth}}">
                            <thead>
                                <tr>
                                    <th width="40" class="th-check text-center">
                                        <div yb-check-box yb-checked="markInfo.allCheckedMaterial"
                                            yb-click="selectAll(orderObj.materialList, 'Material')"></div>
                                    </th>
                                    <th ng-repeat="itemCol in outTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}">
                                        <div yb-thead-operate ng-model="itemCol" target-width="outTbConf.scrollWidth">
                                        </div>
                                    </th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                    <div class="td-scroll" ng-show="orderObj.materialList.length > 0">
                        <table class="table-fixed border-none" width="{{outTbConf.scrollWidth}}">
                            <tbody>
                                <tr ng-repeat="item in orderObj.materialList track by $index">
                                    <td width="40" class="text-center">
                                        <div yb-check-box yb-checked="item.isChecked"
                                            yb-click="selectSingle(item, orderObj.materialList, 'Material')"></div>
                                    </td>
                                    <td ng-repeat="itemCol in outTbConf.tableCol track by $index"
                                        width="{{itemCol.width}}"
                                        ng-class="{'wrapper-none': itemCol.inputType === 'func'}">

                                        <div class="spill-dots"
                                            ng-if="!itemCol.input || item.status == 2 || item.status == 3"
                                            title="{{item[itemCol.dataField]}}">
                                            {{item[itemCol.dataField]}}
                                        </div>

                                        <div ng-if="!!itemCol.input && itemCol.inputType === 'func' && (item.status == 0 || item.status == 1)"
                                            class="td-edit pos-r">
                                            <div yb-form-clear class="td-edit" ng-model="item[itemCol.dataField]"
                                                select-obj="selDepot(item)" clear-form="clearDepot(item)" tips-name="储位"
                                                title="{{item[itemCol.dataField]}}"
                                                ng-class="{'error': !!item.locationErr}">
                                            </div>

                                            <div class="pos-a tool-tips"
                                                ng-if="!!item.locationErr && !item.locationCode">
                                                <i class="triangle"></i>
                                                <div class="msg">请选择储位</div>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="no-data w-full text-center p-t" ng-show="orderObj.materialList.length === 0">暂时没有数据
                    </div>
                </div>
            </div>
            <div class="bottom-area btn-bar text-center clearfix">
                <button type="button" class="btn btn-primary m-r-sm" ng-click="outboundSubmit()">确认出库</button>
                <button type="button" class="btn btn-default" ng-click="cancel()">取消</button>
            </div>
        </div>
    </div>
</div>